package com.shop.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.shop.entity.pojo.Brands;
import com.shop.entity.pojo.Images;
import com.shop.entity.pojo.Style;
import com.shop.entity.pojo.Wares;
import com.shop.admin.service.*;
import com.shop.utils.common.enums.Message;
import com.shop.utils.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/select")
public class AdminSelectListController {

    @Autowired
    private ImagesService imagesService;
    @Autowired
    private BrandsService brandsService;
    @Autowired
    private WaresService waresService;
    @Autowired
    private StyleService styleService;

    @GetMapping("/images_list")
    public Result imagesList(){
        return Result.okResult(imagesService.list(Wrappers.<Images>lambdaQuery().select(Images::getId,Images::getUrl)));
    }

    @GetMapping("/brands_list")
    public Result brandsList(){
        return Result.okResult(brandsService.list(Wrappers.<Brands>lambdaQuery().select(Brands::getId,Brands::getBrandsName)));
    }

    @GetMapping("/wares_list")
    public Result waresList(){
        return Result.okResult(waresService.list(Wrappers.<Wares>lambdaQuery().select(Wares::getId,Wares::getWaresName)
                .eq(Wares::getState, Message.Put)));
    }

    @GetMapping("/style_list")
    public Result styleList(){
        return Result.okResult(styleService.list(Wrappers.<Style>lambdaQuery().select(Style::getId,Style::getStyleName)
                .eq(Style::getState, Message.Put)));
    }

}
